package phaseI;



public class SyntaxTree {

	public TreeNode root;
	
	public SyntaxTree() {
		root = null;
	}
	
	public SyntaxTree(String rootData)	{
		root = new TreeNode(rootData);
	}
	
	public String levelorder() {
		String str = "";
		java.util.LinkedList<TreeNode> list = new java.util.LinkedList<TreeNode>();
		list.add(root);
		while (list.size() != 0) {
			TreeNode node = list.remove();
			if (node != null){
				str += node.toString();
				for (TreeNode n : node.children)
					if (n != null)
						list.add(n);
			}
		}
		return str;
	}
	
	/**
	 * Get a string representing the tree in pre-order form
	 * 
	 * @return the string in pre-order form 
	 */
	/*public String preorder() {
		return preorder(root);
	}
	
	private String preorder(TreeNode t) {
		if (t == null)
			return "";
		else
			return t.toString() + preorder(t.getLeft()) + preorder(t.getRight());
	}
	
	public String postorder() {
		return postorder(root);
	}
	
	private String postorder(TreeNode t) {
		if (t == null)
			return "";
		else
			return postorder(t.getLeft()) + postorder(t.getRight()) + t.toString();
	}
	
	public String inorder() {
		return inorder(root);
	}
	
	private String inorder(TreeNode t)	{
		if (t == null)
			return "";
		else
			return inorder(t.getLeft()) + t.toString() + inorder(t.getRight());
	}*/
}
